import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

// const _import = file => () => import('@views/' + file + '.vue')
const _import = file => require('@views/' + file + '.vue').default
export default new Router({
  // mode: 'history',
  routes: [
    {
      path: '/',
      name: 'layout',
      component: _import('packages/main/layout'),
      redirect: {name: 'activity'},
      children: [
        {
          path: 'activity',
          name: 'activity',
          component: _import('packages/main/activity')
        },
        {
          path: 'mine',
          name: 'mine',
          component: _import('packages/main/mine')
        }
      ]
    },
    /** ************************ 出行人相关   ******************/
    {
      path: '/travel/items',
      name: 'travel.items',
      component: _import('packages/travel/items')
    },
    {
      path: '/travel/add',
      name: 'travel.add',
      component: _import('packages/travel/add')
    },
    {
      path: '/travel/edit/:id(\\d+)?',
      name: 'travel.edit',
      component: _import('packages/travel/edit')
    },
    /** ************************ 设置   ******************/
    {
      path: '/setting',
      name: 'setting',
      component: _import('packages/setting/index')
    },
    /** ************************ 活动相关 ******************/
    {
      path: '/activity/detail/:group_stage_id(\\d+)?',
      name: 'activity.detail',
      component: _import('packages/activity/detail')
    },
    /** ************************ 订单相关   ******************/
    {
      path: '/order/confirm/:group_stage_id(\\d+)?',
      name: 'order.confirm',
      component: _import('packages/order/confirm')
    },
    {
      path: '/order/items/:status(\\d+)?',
      name: 'order.items',
      component: _import('packages/order/items')
    },
    {
      path: '/order/detail/:order_no?',
      name: 'order.detail',
      component: _import('packages/order/detail')
    },
    /** ************************ 意见反馈 ******************/
    {
      path: '/feedback',
      name: 'feedback',
      component: _import('packages/feedback/index')
    },
    /** ************************ 注册 ******************/
    {
      path: '/sign/register',
      name: 'sign.register',
      component: _import('packages/sign/register')
    },
    {
      path: '/sign/authorization',
      name: 'sign.authorization',
      component: _import('packages/sign/authorization')
    }
  ]
})
